<include file="Public:header" />
<div class="page-member subpage">
    <div class="form-header">
        <div>
            <div class="line1">
                <div class="fl"><h3>直管公房申请 / 新增</h3></div>
                <div class="fr hidden">
                    <form class="search-form" method="post" action="">
                        <input name="field" value="{$filter.field}" type="text" />
                        <input name="value" value="{$filter.value}" type="text" />
                        <input name="page" value="{$filter.page}" type="hidden" />
                        <input name="order_field" value="{$filter.order_field}" type="hidden" />
                        <input name="order_sort" value="{$filter.order_sort}" type="hidden" />
                        <button class="btn-normal" type="submit">查 询</button>
                    </form>
                </div>
            </div>
            <div class="line2">
                <div class="fl form-btn-group">
                    <in name="$x|default='02-04-02'" value="$rightsCode">
                        <button onclick="submitForm();" class="btn-save btn-highlight">保 存</button>
                        <else />
                        <button disabled="disabled" class="btn-save btn-disable">保 存</button>
                    </in>
                    <span>或</span>
                    <a class="linkBtn btn-abort" href="/admin/menmian/index">放弃</a>
                </div>
            </div>
        </div>
    </div>
    <div class="form-box2">
        <div>
            <form id="menmianForm" method="post" action="">
                <input type="hidden" name="id" id="id" value="{$menmian.id}" />
                <table class="form">
                    <tr>
                        <th width="15%">姓名<span class="hint">*</span></th>
                        <td width="35%" field="name"><input type="text" name="name" /></td>
                        <th width="15%">性别<span class="hint">*</span></th>
                        <td field="gender"><input type="text" name="gender" /></td>
                    </tr>
                    <tr>
                        <th>联系电话<span class="hint">*</span></th>
                        <td><input type="text" name="phone" /></td>
                        <th>身份证号<span class="hint">*</span></th>
                        <td field="idno"><input type="text" name="idno" /></td>
                    </tr>
                    <tr>
                        <th>居住人口<span class="hint">*</span></th>
                        <td field="resident_num"><input type="text" name="resident_num" /></td>
                        <th>现居住地址</th>
                        <td field="addr"><input type="text" name="addr" /></td>
                    </tr>
                    <tr>
                        <td></td><td></td><td></td><td></td>
                    </tr>
                    <tr>
                        <th>房源地址<span class="hint">*</span></th>
                        <td>
                            <input type="text" name="house_addr" />
                            <input type="hidden" name="house_no" />
                            <input type="hidden" name="house_type" />
                        </td>
                        <th>小区名称<span class="hint">*</span></th>
                        <td><input type="text" name="community" /></td>
                    </tr>
                    <tr>
                        <th>面积</th>
                        <td field="size"><input type="text" name="size" /></td>
                        <th>押金</th>
                        <td field="yj"><input type="text" name="yj" value="{$a|default=C('CONTACT_YAJIN')}" /></td>
                    </tr>
                    <tr>
                        <th>月租金</th>
                        <td field="zj"><input type="text" name="zj" /></td>
                        <th>市场月租金</th>
                        <td field="mzj"><input type="text" name="mzj" /></td>
                    </tr>
                    <tr>
                        <th>备注</th>
                        <td field="remarks"><input type="text" name="remarks" /></td>
                    </tr>
                    <tr>
                        <td></td><td></td><td></td><td></td>
                    </tr>
                    <tr>
                        <th>电子证件</th>
                        <td colspan="3">
                            <table>
                                <tr>
                                    <td>
                                        <img name="sfzImg" style="width:120px;height:80px;" class="img-upload" src="__IMG__/index/sfzzm.png" />
                                    </td>
                                    <td>
                                        <img name="hkbImg" style="width:120px;height:80px;" class="img-upload" src="__IMG__/index/hkb.png" />
                                    </td>
                                    <td>
                                        <img name="yyzzImg" style="width:120px;height:80px;" class="img-upload" src="__IMG__/index/yyzz.png" />
                                    </td>
                                </tr>
                            </table>
                            <input name="upload" class="hidden" type="file" />
                            <input name="sfzImg" type="hidden" value="{$menmian.sfzImg}" />
                            <input name="hkbImg" type="hidden" value="{$menmian.hkbImg}" />
                            <input name="yyzzImg" type="hidden" value="{$menmian.yyzzImg}" />
                        </td>
                    </tr>
                </table>

            </form>
        </div>
    </div>
</div>
<link type="text/css" href="__JS__/autocomplete2/src/jquery.autocomplete.min.css" rel="stylesheet">
<script src="__JS__/autocomplete2/src/jquery.autocomplete.js" type="text/javascript"></script>
<script>
    $('input[name=house_addr]').autocomplete({
        serviceUrl: '/admin/menmian/ajax_SearchHouseByAddr',
        extraParams: {house_addr: $.trim($("input[name=no]").val())},//动态参数值
        paramName: "house_addr",//自定义的参数名 必须和extraParams 参数名相同
        showNoSuggestionNotice: true,
        noSuggestionNotice: '对不起，没有匹配到房源地址',
        onSelect: function (suggestion) {
            $("input[name=community]").val(suggestion.data.community);
            $("input[name=size]").val(suggestion.data.size);
            $("input[name=zj]").val(suggestion.data.price);
            $("input[name=mzj]").val(suggestion.data.mprice);
            $("input[name=house_type]").val(suggestion.data.type);
            $("input[name=house_no]").val(suggestion.data.name);
        }
    });
    $(document).ready(function() {
        $(".img-upload").click(function () {
            $("input[name=upload]").prop("mb", $(this).prop("name")).click();
        });
        $("input[name=upload]").change(function () {
            var self = $(this);
            var form_data = new FormData();
            var file_data = self.prop('files')[0];
            form_data.append('file', file_data);
            $.ajax({
                url: '/home/index/ajax_UploadImg',
                dataType: 'json',
                contentType: false,
                processData: false,
                data: form_data,
                type: 'post',
                success: function(res){
                    if(res.status){
                        self.val(""); //重置文件上传框
                        $("img[name="+self.prop("mb")+"]").prop("src", res.info);
                        $("input[name="+self.prop("mb")+"]").val(res.info);
                    }else{
                        alert(res.info);
                    }
                }
            });
        });

        $("select[name=derate_type]").change(function () {
            var total = parseFloat($("input[name=total]").val());
            var derate = parseFloat($(this).find("option:selected").attr("derate"));
            var derate_money = total * derate;
            $("input[name=total2]").val((total - derate_money).toFixed(2));
            $("input[name=derate_money]").val(derate_money.toFixed(2));
        });
    });
</script>

<script src="__JS__/menmian.js?v=0.4" type="text/javascript" ></script>
<include file="Public:footer" />
